package cn.sccl.dirms.enumConst;

import java.io.Serializable;

/**
 * 操作类型
 * Created by 贺 强 on 2016/3/18.
 */
public enum ResTypeEnum implements Serializable {

    CONTAINER("容器",0),
    GROUP("组",1),
    DEVICE("主机",2),
    APPLICATION("应用集",3),
    GRAPH("图形",4),
    ITEM("监控项",5);

    private String cnName;

    private Integer value;

    private ResTypeEnum() {

    }

    private ResTypeEnum(String cnName, Integer value) {
        this.cnName = cnName;
        this.value = value;
    }

    public String getCnName() {
        return cnName;
    }

    public Integer getValue() {
        return value;
    }

    //根据值获取枚举对象的名称，如果不存在该枚举，返回空串
    public static String getNameByValue(Integer value){
        for(ResTypeEnum e : ResTypeEnum.values()){
            if(value.equals(e.getValue())){
                return e.getCnName();
            }
        }
        return "";
    }

    public static ResTypeEnum getEnumByValue(Integer value){
        for(ResTypeEnum e : ResTypeEnum.values()){
            if(value.equals(e.getValue())){
                return e;
            }
        }
        return null;
    }
}
